//#include <QApplication>
//#include <QPushButton>
//
//int main(int argc, char *argv[]) {
//    QApplication a(argc, argv);
//    QPushButton button("Hello world!", nullptr);
//    button.resize(200, 100);
//    button.show();
//    return QApplication::exec();
//}

#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/core/utils/logger.hpp>
#include "PushOpencv.h"

using namespace std;
using namespace cv;

int main(){
    utils::logging::setLogLevel(utils::logging::LOG_LEVEL_SILENT);
    VideoCapture cap(0);
    if(!cap.isOpened()){
        cout<<"无法打开摄像头！"<<endl;
        return -1;
    }

    PushOpencv *pushUtils = new PushOpencv("rtsp://127.0.0.1:8554/video");
    pushUtils->open_codec(640,480,25);
    pushUtils->start();

    namedWindow("test", WINDOW_AUTOSIZE);

    while (true)
    {
        Mat frame;
        bool bSuccess = cap.read(frame);

        flip(frame,frame,1);

        pushUtils->push_frame(frame);

        if (!bSuccess)
        {
            cout <<""<< endl;
            break;
        }

        imshow("test", frame);

        if (waitKey(1) == 'q')
        {
            break;
        }
    }

    cap.release();
    destroyAllWindows();
    return 0;
}
